package cn.feizhu.aimarket.ai.config;

import com.alibaba.cloud.ai.dashscope.api.DashScopeApi;
import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatModel;
import lombok.Data;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * TODO 简单AIChatModel 用低级模型快速修改Json错误
 *
 * @author feizhu
 * @since 2025/10/16
 */
@Configuration
@ConfigurationProperties(prefix = "ai.simple-chat-model")
@Data
public class SimpleAiChatModelConfig {

    private String apiKey;

    // TODO 这个好像不能加，否则重复url了
//    private String baseUrl;

    private String model;

    /**
     * 用我们自定义的去覆盖默认创建的
     */
    @Bean
    @Primary
    public ChatModel simpleAiChatModel() {
        DashScopeApi dashScopeApi = DashScopeApi.builder()
                .apiKey(apiKey)
                .build();
        return DashScopeChatModel.builder()
                .dashScopeApi(dashScopeApi)
                .build();
    }

}
